package com.wxdc.nmgyt.nmgytwydc.greendao;

import java.util.List;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
import org.greenrobot.greendao.query.Query;
import org.greenrobot.greendao.query.QueryBuilder;

import com.wxdc.nmgyt.nmgytwydc.model.GmYfWzInfoBean;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "GM_YF_WZ_INFO_BEAN".
*/
public class GmYfWzInfoBeanDao extends AbstractDao<GmYfWzInfoBean, Long> {

    public static final String TABLENAME = "GM_YF_WZ_INFO_BEAN";

    /**
     * Properties of entity GmYfWzInfoBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property ID = new Property(1, String.class, "ID", false, "ID");
        public final static Property SHRUBID = new Property(2, String.class, "SHRUBID", false, "SHRUBID");
        public final static Property WZDM = new Property(3, String.class, "WZDM", false, "WZDM");
        public final static Property WZMC = new Property(4, String.class, "WZMC", false, "WZMC");
        public final static Property WZGD = new Property(5, String.class, "WZGD", false, "WZGD");
        public final static Property CFLENGTH = new Property(6, String.class, "CFLENGTH", false, "CFLENGTH");
        public final static Property CFWIDTH = new Property(7, String.class, "CFWIDTH", false, "CFWIDTH");
        public final static Property ZCS = new Property(8, String.class, "ZCS", false, "ZCS");
        public final static Property SHBZ = new Property(9, String.class, "SHBZ", false, "SHBZ");
        public final static Property VERSION = new Property(10, String.class, "VERSION", false, "VERSION");
        public final static Property DBMARK = new Property(11, String.class, "DBMARK", false, "DBMARK");
        public final static Property GmyfInfoId = new Property(12, Long.class, "gmyfInfoId", false, "GMYF_INFO_ID");
    }

    private Query<GmYfWzInfoBean> gmYfInfoBean_SHRUB_WZQuery;

    public GmYfWzInfoBeanDao(DaoConfig config) {
        super(config);
    }
    
    public GmYfWzInfoBeanDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"GM_YF_WZ_INFO_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"ID\" TEXT," + // 1: ID
                "\"SHRUBID\" TEXT," + // 2: SHRUBID
                "\"WZDM\" TEXT," + // 3: WZDM
                "\"WZMC\" TEXT," + // 4: WZMC
                "\"WZGD\" TEXT," + // 5: WZGD
                "\"CFLENGTH\" TEXT," + // 6: CFLENGTH
                "\"CFWIDTH\" TEXT," + // 7: CFWIDTH
                "\"ZCS\" TEXT," + // 8: ZCS
                "\"SHBZ\" TEXT," + // 9: SHBZ
                "\"VERSION\" TEXT," + // 10: VERSION
                "\"DBMARK\" TEXT," + // 11: DBMARK
                "\"GMYF_INFO_ID\" INTEGER);"); // 12: gmyfInfoId
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"GM_YF_WZ_INFO_BEAN\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, GmYfWzInfoBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String ID = entity.getID();
        if (ID != null) {
            stmt.bindString(2, ID);
        }
 
        String SHRUBID = entity.getSHRUBID();
        if (SHRUBID != null) {
            stmt.bindString(3, SHRUBID);
        }
 
        String WZDM = entity.getWZDM();
        if (WZDM != null) {
            stmt.bindString(4, WZDM);
        }
 
        String WZMC = entity.getWZMC();
        if (WZMC != null) {
            stmt.bindString(5, WZMC);
        }
 
        String WZGD = entity.getWZGD();
        if (WZGD != null) {
            stmt.bindString(6, WZGD);
        }
 
        String CFLENGTH = entity.getCFLENGTH();
        if (CFLENGTH != null) {
            stmt.bindString(7, CFLENGTH);
        }
 
        String CFWIDTH = entity.getCFWIDTH();
        if (CFWIDTH != null) {
            stmt.bindString(8, CFWIDTH);
        }
 
        String ZCS = entity.getZCS();
        if (ZCS != null) {
            stmt.bindString(9, ZCS);
        }
 
        String SHBZ = entity.getSHBZ();
        if (SHBZ != null) {
            stmt.bindString(10, SHBZ);
        }
 
        String VERSION = entity.getVERSION();
        if (VERSION != null) {
            stmt.bindString(11, VERSION);
        }
 
        String DBMARK = entity.getDBMARK();
        if (DBMARK != null) {
            stmt.bindString(12, DBMARK);
        }
 
        Long gmyfInfoId = entity.getGmyfInfoId();
        if (gmyfInfoId != null) {
            stmt.bindLong(13, gmyfInfoId);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, GmYfWzInfoBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String ID = entity.getID();
        if (ID != null) {
            stmt.bindString(2, ID);
        }
 
        String SHRUBID = entity.getSHRUBID();
        if (SHRUBID != null) {
            stmt.bindString(3, SHRUBID);
        }
 
        String WZDM = entity.getWZDM();
        if (WZDM != null) {
            stmt.bindString(4, WZDM);
        }
 
        String WZMC = entity.getWZMC();
        if (WZMC != null) {
            stmt.bindString(5, WZMC);
        }
 
        String WZGD = entity.getWZGD();
        if (WZGD != null) {
            stmt.bindString(6, WZGD);
        }
 
        String CFLENGTH = entity.getCFLENGTH();
        if (CFLENGTH != null) {
            stmt.bindString(7, CFLENGTH);
        }
 
        String CFWIDTH = entity.getCFWIDTH();
        if (CFWIDTH != null) {
            stmt.bindString(8, CFWIDTH);
        }
 
        String ZCS = entity.getZCS();
        if (ZCS != null) {
            stmt.bindString(9, ZCS);
        }
 
        String SHBZ = entity.getSHBZ();
        if (SHBZ != null) {
            stmt.bindString(10, SHBZ);
        }
 
        String VERSION = entity.getVERSION();
        if (VERSION != null) {
            stmt.bindString(11, VERSION);
        }
 
        String DBMARK = entity.getDBMARK();
        if (DBMARK != null) {
            stmt.bindString(12, DBMARK);
        }
 
        Long gmyfInfoId = entity.getGmyfInfoId();
        if (gmyfInfoId != null) {
            stmt.bindLong(13, gmyfInfoId);
        }
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public GmYfWzInfoBean readEntity(Cursor cursor, int offset) {
        GmYfWzInfoBean entity = new GmYfWzInfoBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // ID
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // SHRUBID
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // WZDM
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // WZMC
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // WZGD
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // CFLENGTH
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // CFWIDTH
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // ZCS
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // SHBZ
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // VERSION
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // DBMARK
            cursor.isNull(offset + 12) ? null : cursor.getLong(offset + 12) // gmyfInfoId
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, GmYfWzInfoBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setID(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setSHRUBID(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setWZDM(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setWZMC(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setWZGD(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setCFLENGTH(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setCFWIDTH(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setZCS(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setSHBZ(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setVERSION(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setDBMARK(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
        entity.setGmyfInfoId(cursor.isNull(offset + 12) ? null : cursor.getLong(offset + 12));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(GmYfWzInfoBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(GmYfWzInfoBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(GmYfWzInfoBean entity) {
        return entity.getId() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
    /** Internal query to resolve the "SHRUB_WZ" to-many relationship of GmYfInfoBean. */
    public List<GmYfWzInfoBean> _queryGmYfInfoBean_SHRUB_WZ(Long gmyfInfoId) {
        synchronized (this) {
            if (gmYfInfoBean_SHRUB_WZQuery == null) {
                QueryBuilder<GmYfWzInfoBean> queryBuilder = queryBuilder();
                queryBuilder.where(Properties.GmyfInfoId.eq(null));
                gmYfInfoBean_SHRUB_WZQuery = queryBuilder.build();
            }
        }
        Query<GmYfWzInfoBean> query = gmYfInfoBean_SHRUB_WZQuery.forCurrentThread();
        query.setParameter(0, gmyfInfoId);
        return query.list();
    }

}
